//
//  VersifyCodeInputPublisher.swift
//  casdon_swiftUI
//
//  Created by ww on 2025/5/18.
//


import Combine
import Foundation

extension Notification.Name {
    // 验证码输入通知
    static let verificationCodeEntered = Notification.Name("verificationCodeEntered")
}

final class CodeNotificationBridge {
    static let shared = CodeNotificationBridge()
    
    let codeSubject = PassthroughSubject<String, Never>()
    private var cancellable: AnyCancellable?

    private init() {
        cancellable = NotificationCenter.default
            .publisher(for: .verificationCodeEntered)
            .compactMap { $0.userInfo?["code"] as? String }
            .sink { [weak self] code in
                self?.codeSubject.send(code)
            }
    }
}

